unit UDefaultDataModule;

interface

uses
  SysUtils, Classes;

type
  TFieldMetaData = class(TComponent)
  private
    FRequired: boolean;
    FisPrimatyKey: boolean;
    FTableName: String;
    FDataType: String;
    FName: String;
    procedure SetDataType(const Value: String);
    procedure SetisPrimatyKey(const Value: boolean);
    procedure SetName(const Value: String);
    procedure SetRequired(const Value: boolean);
    procedure SetTableName(const Value: String);
  protected
  public
    constructor create(AOwner : TComponent);Override;
  published
    property Name : String read FName write SetName;
    property DataType : String read FDataType write SetDataType;
    property isPrimatyKey : boolean read FisPrimatyKey write SetisPrimatyKey;
    property TableName : String read FTableName write SetTableName;
    property Required : boolean read FRequired write SetRequired;

  end;//TFieldMetaData

  TTableMetaData = class(TComponent)
  private
    fields : TList;
    FPrimaryKeysNames: String;
    FTableName: String;
    _Aowner : TComponent;
    procedure SetPrimaryKeysNames(const Value: String);
    procedure SetTableName(const Value: String);
  protected
  public
    function Field(index : integer):TFieldMetaData;
    function KeyField(index : integer):TFieldMetaData;
    function FieldCount : Integer;
    function KeyFieldCount : Integer;
    function DDLSQL : String;
    function InsertSQL : String;
    function UpdateSQL : String;
    function DeleteSQL : String;
    procedure addField(field : TFieldMetaData);
    constructor create(AOwner : TComponent);Override;
    destructor Destroy; Override;
  published
    property TableName : String read FTableName write SetTableName;
    property PrimaryKeysNames : String read FPrimaryKeysNames write SetPrimaryKeysNames;

  end;//TTableMetaData

  TDefaultDataModule = class(TDataModule)
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  DefaultDataModule: TDefaultDataModule;

implementation

{$R *.dfm}

{ TTableMetaData }

procedure TTableMetaData.addField(field: TFieldMetaData);
begin
   fields.add(field);
end;

constructor TTableMetaData.create(AOwner: TComponent);
begin
  inherited;
  _Aowner := AOwner;
  fields := TList.Create;
end;

function TTableMetaData.DDLSQL: String;
begin

end;

function TTableMetaData.DeleteSQL: String;
begin

end;

destructor TTableMetaData.Destroy;
var temp : TFieldMetaData;
  i : integer;
begin
  for i := 0 to fields.Count- 1 do
  begin
    temp := fields[i];
    fields.Remove(temp);
    FreeAndNil(temp);
  end;
  FreeAndNil(fields);
  inherited;
end;

function TTableMetaData.Field(index: integer): TFieldMetaData;
begin

end;

function TTableMetaData.FieldCount: Integer;
begin

end;

function TTableMetaData.InsertSQL: String;
begin

end;

function TTableMetaData.KeyField(index: integer): TFieldMetaData;
begin

end;

function TTableMetaData.KeyFieldCount: Integer;
begin

end;

procedure TTableMetaData.SetPrimaryKeysNames(const Value: String);
begin
  FPrimaryKeysNames := Value;
end;

procedure TTableMetaData.SetTableName(const Value: String);
begin
  FTableName := Value;
end;

function TTableMetaData.UpdateSQL: String;
begin

end;

{ TFieldMetaData }

constructor TFieldMetaData.create(AOwner: TComponent);
begin
  inherited;
   
end;

procedure TFieldMetaData.SetDataType(const Value: String);
begin
  FDataType := Value;
end;

procedure TFieldMetaData.SetisPrimatyKey(const Value: boolean);
begin
  FisPrimatyKey := Value;
end;

procedure TFieldMetaData.SetName(const Value: String);
begin
  FName := Value;
end;

procedure TFieldMetaData.SetRequired(const Value: boolean);
begin
  FRequired := Value;
end;

procedure TFieldMetaData.SetTableName(const Value: String);
begin
  FTableName := Value;
end;

end.
